using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Windows;




public class Move : MonoBehaviour
{
    public bool m_MovingLeft = false;
    public bool m_MovingRight = false;

    public Vector3 movedir;
    public float movespeed = 10f;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (m_MovingLeft)
        {
            Moveing(-1);
        }
        else if (m_MovingRight)
        {
            Moveing(1);
        }
    }

    public void StartMovingLeft()
    {
        m_MovingLeft = true;
    }

    public void StopMoving()
    {
        m_MovingLeft = false;
        m_MovingRight = false;
        GetComponent<Rigidbody2D>().velocity = Vector2.zero;
    }

    public void StartMovingRight()
    {
        m_MovingRight = true;
    }

    public void Moveing(float dir)
    {
        Vector3 offset = new Vector3(movespeed * dir, 0, 0);
        GetComponent<Rigidbody2D>().velocity = offset;

    }
}
